package actions;

import constants.*;


import interfaces.impl.Action;
import objects.SpetialFeature;
import objects.WorldObject;
import universe.Universe;

public class ActionAttack extends Action{
	
	

	public ActionAttack(){
		this.id=Constants.ACTION_ATTACK;
	}
	
	public ActionAttack(WorldObject source, WorldObject target) {
		super(source, target);
		this.id=Constants.ACTION_ATTACK;
		
	}
	
	public ActionAttack( int priority){
		super(priority);
		this.id=Constants.ACTION_ATTACK;
	}

	

	@Override
	public boolean processAction(Universe world) {
		double damage=0;
		
		for(SpetialFeature feature : source.getListFeatures()){
			if(feature.getId()==Constants.SPETIAL_FEATURE_DAMAGE){
				damage=feature.getValue();
				break;
			}
		}
		for(SpetialFeature feature : target.getListFeatures()){
			if(feature.getId()==Constants.SPETIAL_FEATURE_CURRENT_LIFE){
				//validate that life cant be < 0  
				feature.setValue(feature.getValue()-damage);
				/*if(feature.getValue()<=0){
					world.getListObjectsToKill().add(target);
				}*/
				return true;
				
			}
		}
		
		return false;
	}

	@Override
	public String getName() {
		// TODO Auto-generated method stub
		return "ataque";
	}

	
	
}
